package com.lifeservice.console.service.impl;

import com.lifeservice.common.utils.DateUtils;
import com.lifeservice.console.domain.LifeWxuser;
import com.lifeservice.console.mapper.LifeWxuserMapper;
import com.lifeservice.console.service.ILifeWxuserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 微信用户Service业务层处理
 *
 * @author lifeservice
 * @date 2023-02-27
 */
@Service
public class LifeWxuserServiceImpl implements ILifeWxuserService {
    @Autowired
    private LifeWxuserMapper lifeWxuserMapper;

    /**
     * 查询微信用户
     *
     * @param id 微信用户主键
     * @return 微信用户
     */
    @Override
    public LifeWxuser selectLifeWxuserById(String id) {
        return lifeWxuserMapper.selectLifeWxuserById(id);
    }

    /**
     * 查询微信用户列表
     *
     * @param lifeWxuser 微信用户
     * @return 微信用户
     */
    @Override
    public List<LifeWxuser> selectLifeWxuserList(LifeWxuser lifeWxuser) {
        return lifeWxuserMapper.selectLifeWxuserList(lifeWxuser);
    }

    /**
     * 新增微信用户
     *
     * @param lifeWxuser 微信用户
     * @return 结果
     */
    @Override
    public int insertLifeWxuser(LifeWxuser lifeWxuser) {
        lifeWxuser.setCreateTime(DateUtils.getNowDate());
        return lifeWxuserMapper.insertLifeWxuser(lifeWxuser);
    }

    /**
     * 修改微信用户
     *
     * @param lifeWxuser 微信用户
     * @return 结果
     */
    @Override
    public int updateLifeWxuser(LifeWxuser lifeWxuser) {
        lifeWxuser.setUpdateTime(DateUtils.getNowDate());
        return lifeWxuserMapper.updateLifeWxuser(lifeWxuser);
    }

    /**
     * 批量删除微信用户
     *
     * @param ids 需要删除的微信用户主键
     * @return 结果
     */
    @Override
    public int deleteLifeWxuserByIds(String[] ids) {
        return lifeWxuserMapper.deleteLifeWxuserByIds(ids);
    }

    /**
     * 删除微信用户信息
     *
     * @param id 微信用户主键
     * @return 结果
     */
    @Override
    public int deleteLifeWxuserById(String id) {
        return lifeWxuserMapper.deleteLifeWxuserById(id);
    }

    /**
     * 通过OpenID查询微信用户信息
     *
     * @param openid
     * @return
     */
    @Override
    public LifeWxuser selectWxuserOpenID(String openid) {
        return lifeWxuserMapper.selectWxuserOpenID(openid);
    }
}
